﻿using System;
using System.Collections.Generic;
using NUnit.Framework;
using CI.Interfaces;
using Rhino.Mocks;

namespace Mesopotamia.UnitTests
{
    [TestFixture]
    public class GridWSDALTests
    {
        private CI.DAL.GridWSDAL _gridWSDAL;
        private IHostingEnvironment _hostingEnvironment;
        private string _environmentName;
        private MockRepository _mocks;

        [SetUp]
        public void Setup()
        {
            _gridWSDAL = new CI.DAL.GridWSDAL();
            _environmentName = "Mesopotamia";
            _mocks = new MockRepository();
            _hostingEnvironment = _mocks.DynamicMock<IHostingEnvironment>();
            _mocks.DynamicMock<IHostingEnvironmentPhysical>();
        }


        /// <summary>
        /// Test to make sure it throw and exception on null or empty exception string
        /// </summary>
        [Test, ExpectedException(typeof(ArgumentException), ExpectedMessage = "environment")]
        public void LoadNullEnvironmentException()
        {
            _gridWSDAL.LoadHostingEnvironment(null, _hostingEnvironment, 0, new List<Guid>());
        }

        /// <summary>
        /// Test to make sure it throw and exception on null hosting environment
        /// </summary>
        [Test, ExpectedException(typeof(ArgumentException), ExpectedMessage = "hostEnvironment")]
        public void LoadNullHostingEnvironmentException()
        {
            _gridWSDAL.LoadHostingEnvironment(_environmentName, null, 0, new List<Guid>());
        }

        /// <summary>
        /// Test to make sure it throw and exception on null or empty exception string
        /// </summary>
        [Test, ExpectedException(typeof(ArgumentException), ExpectedMessage = "environment")]
        public void SaveOrganismsNullEnvironmentException()
        {
            _gridWSDAL.SaveHostingEnvironment(null, _hostingEnvironment, 0);
        }

        /// <summary>
        /// Test to make sure it throw and exception on null hosting environment
        /// </summary>
        [Test, ExpectedException(typeof(ArgumentException), ExpectedMessage = "hostEnvironment")]
        public void SaveOrganismsNullHostingEnvironmentException()
        {
            _gridWSDAL.SaveHostingEnvironment(_environmentName, null, 0);
        }
    }
}
